﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>项目节点管理</title>
    <link href="~/Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/knockout-min.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/js/common.js"></script>
    <script src="~/Content/js/module_cols_defined.js"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <link href="~/Content/formstyles.css" rel="stylesheet" />
    <script type="text/javascript">
        var pk = "ProjectNo";//不隐藏的主键
        var module_dialog="#module_dialog";
        var flag = "PMIndex";//页面标签       
        var currentUserId = window.parent.RealName || "test_admin";//当前用户
        //var initColumnMap = {
        //    'ProjectNo': true,
        //    'Department': true,
        //    'ProjectName': true,
        //};
        //console.log(currentUserId, initColumnMap, pk, flag); 
        //console.log();
        //$(function(){
            //$("#module_column_defined_dialog").dialog($.extend({}, dialogParam, dialogParamObj));
            //loadColumnDefined(currentUserId,initColumnMap,pk,flag);
        //});

        var currentpagedata = {
        }
        var view = getQueryVariable("view") || "PMMaintain";
        var ProjectNo = getQueryVariable("ProjectNo") || "";//传入的项目编码
        var ProjectID = getQueryVariable("ProjectID") || "";//传入的项目id
        var lock = false;//全局操作锁
        var pmbaseData;
        var viewModel;

        $(function () {
            //获取项目数据
            $.getJSON("/Project/GetAllPMInfo?&ProjectID=" + ProjectID, function (data) {
                pmbaseData = data.rows[0];
                viewModel = {
                    unitName: ko.observable(''),
                    address: ko.observable(''),
                    ProjectName: ko.observable(pmbaseData.ProjectName),
                    ProjectNo: ko.observable(pmbaseData.ProjectNo),
                    ProjectID: ko.observable(pmbaseData.ProjectID),
                    FStatus: ko.observable('未绑定zt'),
                    FStart: ko.observable('未绑定')
                };
                ko.applyBindings(viewModel);//完成绑定
            });
           
        });
        //菜单标灰处理函数
        function menuControl() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");        
            switch(rows[0].status) {
                case "":                   
                case 0:
                    $("#delete").linkbutton("enable");//允许删除
                    $("#confirm").linkbutton("enable");
                    $("#unconfirm").linkbutton("disable");
                    $("#assign").linkbutton("disable");
                    $("#unassign").linkbutton("disable");
                    break;
                case 1:
                    $("#delete").linkbutton("disable");//禁止删除
                    $("#confirm").linkbutton("disable");
                    $("#unconfirm").linkbutton("enable");
                    $("#assign").linkbutton("enable");
                    $("#unassign").linkbutton("disable");
                    break;
                case 2:
                    $("#delete").linkbutton("disable");//禁止删除
                    $("#confirm").linkbutton("disable");
                    $("#unconfirm").linkbutton("disable");
                    $("#assign").linkbutton("disable");
                    $("#unassign").linkbutton("enable");
                    break;
                case 3:
                    $("#delete").linkbutton("disable");//禁止删除
                    break;
                default:
                    $("#delete").linkbutton("disable");//禁止删除 
                    break;
            }

        }
        //显示/隐藏 toolbar按钮 
        function easyRightDisplay() {
            //获取所有的toolbar按钮
            var button = $('div.datagrid div.datagrid-toolbar a');
            for (var i = 0; i < button.length; i++) {
                var toolbar = button[i];
                var id = toolbar.id;
                if (id == "add") {  //隐藏Id为add的按钮
                    $('div.datagrid div.datagrid-toolbar a').eq(i).hide();
                }
                if (id == "delete") {  //不隐藏id为delete的按钮
                    //button.eq(i).hide();
                }
                //如果按钮都没权限，隐藏了可直接隐藏toolbar
                //$('div.datagrid div.datagrid-toolbar').hide();
            }
        }
      

        //查看横道图
        function pmGantt() {

            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row == null) {
                $.show_alert("提示", "请先勾选项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量处理项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            window.parent.addTab(row.ProjectName, '/Project/gantt_singleP?ProjectID=' + row.ProjectID);

        }

 //成本管理功能模块
  function costMgr() {
            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row==null) {
                $.show_alert("提示", "请先勾选项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量处理项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $("<div/>").dialog({
                id: "ui_pm_cost_dialog",
                href: "/Project/PMCost",
                queryParams: {
                    ProjectID: row.ProjectID,
                    ProjectNo: row.ProjectNo,
                    ProjectName: row.ProjectName,
                    IcmoNo: row.IcmoNo,//关联主单号
                    FitemNo: row.FitemNo,//关联物料
                    FModel: row.FModel,//关联物料
                    FName: row.FName,//关联物料                    
                    estcost: row.estCost,//预估成本
                    budCost:row.budCost,//预算成本
                    stdCost:row.stdCost,//标准成本
                    reaCost: row.reaCost,//实际成本

                },
           
                title: "成本管理",
                height: $(window).height(),
                width: $(window).width(),
                modal: true,
                toolbar: [],
                onClose: function () {
                    $("#ui_pm_cost_dialog").dialog('destroy');  //销毁dialog对象
                    $("#ui_pm_dg").datagrid("reload");//刷新主表
                }
            })

        }

 //新增项目
  function AddPMIndex() {
            $("<div/>").dialog({
                 id: "ui_pm_add_dialog",
                 href: "/Project/PMEdit",
                 title: "新增项目",
                 height: $(window).height(),
                 width: $(window).width(),
                 modal:true,
                 toolbar: [{
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        if (lock) { return; } else { lock = true; }
                        $.ajax({     //提交数据保存
                            url: "/Project/AddNewProject?r=" + Math.random(),
                            type: "post",
                            data: {
                                "KeyCode": "CreatePMBill",
                                "ProjectID": $("#ProjectID").val(),
                                "ProjectNo": $("#ProjectNo").val(),
                                "ProjectName": $("#ProjectName").val(),
                                "ProjectManager": $("#ProjectManager").val(),
                                "ProjectClerk": $("#ProjectClerk").val(),
                                "Remark": $("#Remark").val(),                           
                                "Department": $("#comDepartmentList").val(),
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                lock = false;
                                if (data.success) {
                                    $.show_alert("成功", "保存成功！");
                                    $("#ui_pm_add_dialog").dialog('destroy');
                                    $("#ui_pm_dg").datagrid("reload");//.datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        })
                        
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-cross',
                    handler: function () { $("#ui_pm_add_dialog").dialog('destroy'); }
                }],
                onLoad: function () {
                    $("#ProjectNo").textbox('enable');
                    $("#ProjectName").textbox('enable');
                    $("#ProjectManager").textbox('enable');
                    $("#ProjectClerk").textbox('enable');
                    $("#Remark").textbox('enable');
                    $("#CreateBy").attr('hidden', 'hidden');
                    $("#CreateTime").attr('hidden', 'hidden');
                    $("#UpdateTime").attr('hidden', 'hidden');
                    $("#UpdateBy").attr('hidden', 'hidden');
                    $("#tt").attr('hidden', 'hidden');//隐藏节点管理
                },
                onClose: function () {
                    $("#ui_pm_add_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }

        
  //项目管理角色授权：用于成本查看权限的管控
    function RoleAuthorize() {     
            $("<div/>").dialog({
                id: "ui_pm_dg_role_authorize_dialog",
                href: "/Project/ProjectRoleAuthorize",
                title: "角色授权：",
                height: 280,
                width: 420,
                modal: true,
                buttons: [{
                    id: "ui_pm_setrole_btn",
                    text: '确 定',
                    handler: function () {
                        $("#SetPmRoleForm").form("submit", {
                            url: "/PMCost/SetRoleField",
                            onSubmit: function (param) {
                                $('#ui_pm_setrole_btn').linkbutton('disable');
                                param.fieldName = $("#fieldName").combobox('getValue');
                                param.RoleIDs = $("#comboxrole").combobox('getValues');
                            },
                            success: function (data) {
                                var dataJson = eval('(' + data + ')');
                                if (dataJson.success) {
                                    $("#ui_pm_dg_role_authorize_dialog").dialog('destroy');
                                    $.show_alert("提示", dataJson.msg);
                                   // $("#ui_user_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $('#ui_pm_setrole_btn').linkbutton('enable');
                                    $.show_alert("提示", dataJson.msg);
                                }
                            }
                        });
                    }
                }],
                onLoad: function () {
                    //如果是设置一个用户就自动勾选已经有的角色
                    //if (row.length == 1) {
                    //    $('#comboxrole').combobox('setValues', stringToList(row[0].UserRoleId));
                    //    $("#hiduserid").val(row[0].ID);
                    //    $("#txtusernameR").val(row[0].AccountName);
                    //}
                    //else {
                    //    var userids = "";
                    //    var usernames = "";
                    //    for (var i = 0; i < row.length; i++) {
                    //        userids += row[i].ID + ",";
                    //        usernames += row[i].AccountName + ",";
                    //    }
                    //    $("#hiduserid").val(userids.substring(0, userids.length - 1));
                    //    $("#txtusernameR").val(usernames.substring(0, usernames.length - 1));
                    //}
                },
                onClose: function () {
                    $("#ui_pm_dg_role_authorize_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }


        //从前端导出,只能用模拟表单
        // 直接通过ajax请求文件数据，jquery下载文件时不能触发浏览器弹出保存文件对话框！ 可以在javascript中访问下载的文件数据   
        // 模拟表单提交同步方式下载文件
        // 能够弹出保存文件对话框
        function PMIndexExport() {
            //console.log("ajaxDownloadSynchronized");
            var rows = $("#ui_pm_dg").datagrid("getRows");
            for (var i = 0; i < rows.length; i++) {    //进行数据处理
                switch (rows[i].status) {
                    case 0:
                        rows[i].status = "待确认";
                        break;
                    case 1:
                        rows[i].status = "已确认";
                        break;
                    case 2:
                        rows[i].status = "已下达";
                        break;
                    case 3:
                        rows[i].status = "已结项";
                        break;
                    case 5:
                        rows[i].status = "已终止";
                        break;
                    default:                         
                        break;
                }
            //移除不要的字段
                delete rows[i].ProjectID;
            //delete rows[i].SaleOrderId;
            //delete rows[i].SaleOrderItems;
            //delete rows[i].SaleStatus;
            //delete rows[i].UserName;
            //delete rows[i].Customer;
            //delete rows[i].AddDate;
            }
            var bodyData = JSON.stringify(rows);  //转成json字符串
            //替换中文标题
            var a = bodyData.replace(/ProjectNo/g, "项目编码").replace(/ProjectName/g, "项目名称").replace(/status/g, "状态")
            .replace(/ProjectClerk/g, "业务员").replace(/ProjectManager/g, "管理员").replace(/EstWorkTime/g, "预估工时").replace(/UpdateBy/g, '最后更新人')
            .replace(/UpdateTime/g, "最后更新时间").replace(/Remark/g, "项目描述").replace(/CreateBy/g, "创建人").replace(/CreateTime/g, "创建时间");
            //var postData = {
            //    data: bodyData
            //};
         
            var url = "/Project/ExportExcel";
            var fileName = "testAjaxDownload.xls";
            var form = $("<form></form>").attr("action", url).attr("method", "post");
            form.append($("<input></input>").attr("type", "hidden").attr("name", "bodyData").attr("value", a));
            form.appendTo('body').submit().remove();            
        }

        //从前端导出
        function exportPMIndex2() {
            var rows = $("#ui_pm_dg").datagrid("getRows");


            //for (var i = 0; i < rows.length; i++) {    //进行数据处理
                //if (isArray(rows[i].OrganizedId)) {
                //    rows[i].OrganizedId = rows[i].OrganizedId[0];
                //}
                //if (isArray(rows[i].CustomerId)) {
                //    rows[i].CustomerId = rows[i].CustomerId[0];
                //}
                //if (rows[i].AdvanceDate != null) {
                //    var unix = rows[i].AdvanceDate.replace("/Date(", "").replace(")/", "");
                //    var un = unix.substring(0, 10);
                //    var newDate = new Date();
                //    newDate.setTime(un * 1000);

                //    rows[i].AdvanceDate = newDate.toLocaleString();
                //}
                //if (rows[i].OrderDate != null) {
                //    var unix = rows[i].OrderDate.replace("/Date(", "").replace(")/", "");
                //    var un = unix.substring(0, 10);
                //    var newDate = new Date();
                //    newDate.setTime(un * 1000);

                //    rows[i].OrderDate = newDate.toLocaleString();
                //}
                //if (rows[i].RetainageDate != null) {
                //    var unix = rows[i].RetainageDate.replace("/Date(", "").replace(")/", "");
                //    var un = unix.substring(0, 10);
                //    var newDate = new Date();
                //    newDate.setTime(un * 1000);

                //    rows[i].RetainageDate = newDate.toLocaleString();
                //}

                ////移除不要的字段
                //delete rows[i].SaleAtts;
                //delete rows[i].SaleOrderId;
                //delete rows[i].SaleOrderItems;
                //delete rows[i].SaleStatus;
                //delete rows[i].UserName;
                //delete rows[i].Customer;
                //delete rows[i].AddDate;

            //}
            var bodyData = JSON.stringify(rows);  //转成json字符串

            //替换中文标题
           // var a = bodyData.replace(/SaleOrderNo/g, "订单编号").replace(/OrderType/g, "订单类型").replace(/FromWhere/g, "订单来源")
           //.replace(/OrganizedId/g, "机构").replace(/SaleUser/g, "销售员").replace(/SaleTc/g, "销售提成").replace(/OrderDate/g, '订单日期')
           //.replace(/ContractNo/g, "合同编号").replace(/Amount/g, "总额").replace(/Advance/g, "首付款").replace(/AdvanceDate/g, "首付款日期")
           //.replace(/PayMethod/g, "支付方式").replace(/Retainage/g, "尾款").replace(/RetainageDate/g, "尾款日期").replace(/InlayPrice/g, "镶嵌款")
           //.replace(/CustManager/g, "客户经理").replace(/EquityNo/g, "认股书编号").replace(/LogisticsTotal/g, "物流费用")
           //.replace(/Remarks/g, "备注").replace(/CompletedStatus/g, "状态").replace(/CustomerId/g, "终端客户");

            var postData = {
                data: bodyData
            };

            //$.ajax({
            //    type: "POST",
            //    url: "ExportExcel",
            //    data: postData,
            //    success: function (data) {
            //        if (data == "1") {
            //            layer.msg("操作成功,文件在桌面！", {
            //                icon: 6,
            //                time: 2000,
            //            });
            //        } else if (data == "-1") {
            //            layer.msg("操作失败！", { icon: 2 });
            //        }
            //    }
            //});
        }
        //修改项目
        function EditPMIndex() {
            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row==null) {
                $.show_alert("提示", "请先勾选要更新的项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量修改项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $("<div/>").dialog({
                id: "ui_pm_edit_dialog",
                href: "/Project/PMEdit",
                title: "更新项目",
                height: $(window).height(),
                width: $(window).width(),
                modal: true,
                toolbar: [{
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        if (lock) { return; } else { lock = true; }
                        $.ajax({     //提交数据保存
                            url: "/Project/EditBasicProject?r=" + Math.random(),
                            type: "post",
                            data: {
                                "KeyCode": "EditPMBill",
                                "ProjectID": $("#ProjectID").val(),
                                "ProjectNo": $("#ProjectNo").val(),
                                "ProjectName": $("#ProjectName").val(),
                                "ProjectManager": $("#ProjectManager").val(),
                                "ProjectClerk": $("#ProjectClerk").val(),
                                "Remark": $("#Remark").val()
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                lock = false;
                                if (data.success) {
                                    $.show_alert("成功", "保存成功！");
                                    $("#ui_pm_edit_dialog").dialog('destroy');
                                    $("#ui_pm_dg").datagrid("reload");//.datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        })
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-cross',
                    handler: function () { $("#ui_pm_edit_dialog").dialog('destroy'); }
                }],
                onLoad: function () {
                    $("#ProjectID").val(row.ProjectID);
                    $("#ProjectNo").textbox('setValue', row.ProjectNo);
                    $("#ProjectName").textbox('setValue', row.ProjectName);
                    $("#ProjectManager").textbox('setValue', row.ProjectManager);
                    $("#ProjectClerk").textbox('setValue', row.ProjectClerk);
                    $("#CreateBy").textbox('setValue', row.CreateBy);
                    $("#CreateTime").textbox('setValue', row.CreateTime);
                    $("#UpdateTime").textbox('setValue', row.UpdateTime);
                    $("#UpdateBy").textbox('setValue', row.UpdateBy);
                    $("#Remark").textbox('setValue', row.Remark);
                    $("#ProjectNo").textbox('enable');
                    $("#ProjectName").textbox('enable');
                    $("#ProjectManager").textbox('enable');
                    $("#ProjectClerk").textbox('enable');
                    $("#Remark").textbox('enable');
                    $("#com").hide();
                    $("#dep").hide();
                    $("#tt").attr('hidden', 'hidden');//隐藏节点管理

                },
                onClose: function () {
                    $("#ui_pm_edit_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
        }
        //删除项目
        function DelPMIndex() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要删除的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量删除");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '确定删除：' + rows[0].ProjectName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/DelProjectByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].ProjectID
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }

        //项目状态：确认
        function confirmPMIndex() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要确认的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '确认该项目：' + rows[0].ProjectName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/confirmProjectByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].ProjectID,
                            confirm: "confirm"
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        //取消确认项目
        function unconfirmPMIndex() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要取消确认的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '取消确认该项目：' + rows[0].ProjectName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/confirmProjectByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].ProjectID,
                            confirm: "unconfirm"
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        //下达任务
        function assignPMIndex() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要下达的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '下达该项目：' + rows[0].ProjectName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/confirmProjectByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].ProjectID,
                            confirm: "2"//1，已确认；2,已下达
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        //取消下达任务状态
        function unassignPMIndex() {
            var rows = $("#ui_pm_dg").datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要取消下达的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '取消下达该项目：' + rows[0].ProjectName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/confirmProjectByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].ProjectID,
                            confirm: "1" //改为已确认
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        function ui_pm_searchdata() {
            $("#ui_pm_dg").datagrid('load', {
                ProjectNo: $('#txtProjectNo').val(),
                ProjectName: $('#txtPMName').val(),
                status: $('#FStatus').val(),
                CreateTimeS: $('#txtAddBeginDate').datetimebox('getValue'),
                CreateTimeE: $('#txtAddEndDate').datetimebox('getValue')
            });
            // $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
        }

        function ui_pm_cleardata() {
            $('#ui_pm_search input').val('');
            $('#ui_pm_search select').val('select');
            $('#txtAddBeginDate').datetimebox('setValue', '');
            $('#txtAddEndDate').datetimebox('setValue', '');
            $("#ui_pm_dg").datagrid('load', {});//清空条件自动加载数据

            //  $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
        }

        function uploadfile(appendlistid, appenddatagrid) {
            $("<div/>").dialog({
                id: "ui_pm_upload_dialog",
                href: "/Project/uploadform",
                title: "上传附件",
                height: 270,
                width: 510,
                modal: true,
                buttons: [{
                    id: "ui_file_add_btn",
                    text: '添 加',
                    handler: function () {
                        //获取上传文件控件内容
                        var file = $("#fileImport").filebox("files")[0];
                        //判断控件中是否存在文件内容，如果不存在，弹出提示信息，阻止进一步操作
                        if (file == null) { alert('错误，请选择文件'); return; }
                        //获取文件名称
                        var fileName = file.name;
                        //获取文件类型名称
                        var file_typename = fileName.substring(fileName.lastIndexOf('.'), fileName.length);
                        //这里限定上传文件文件类型必须为.xlsx，如果文件类型不符，提示错误信息
                        if (file_typename == '.xlsx' || true) {
                            //计算文件大小
                            var fileSize = 0;
                            //如果文件大小大于1024字节X1024字节，则显示文件大小单位为MB，否则为KB
                            if (file.size > 1024 * 1024) {
                                fileSize = Math.round(file.size * 100 / (1024 * 1024)) / 100;
                                if (fileSize > 10) {
                                    alert('错误，文件超过10MB，禁止上传！'); return;
                                }
                                fileSize = fileSize.toString() + 'MB';
                            }
                            else {
                                fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
                            }
                            //将文件名和文件大小显示在前端label文本中
                            document.getElementById('fileName').innerHTML = "<span style='color:Blue'>文件名: " + file.name + ',大小: ' + fileSize + "</span>";
                            //获取form数据
                            var formData = new FormData($("#importFileForm")[0]);
                            //调用apicontroller后台action方法，将form数据传递给后台处理。contentType必须设置为false,否则chrome和firefox不兼容
                            $.ajax({
                                url: "/Project/uploadfile?appendlistid=" + appendlistid + "&r=" + Math.random(),
                                type: 'POST',
                                data: formData,
                                async: false,
                                cache: false,
                                contentType: false,
                                processData: false,
                                success: function (returnInfo) {
                                    //上传成功后将控件内容清空，并显示上传成功信息
                                    document.getElementById('fileImport').value = null;
                                    document.getElementById('uploadInfo').innerHTML = "<span style='color:Red'>" + returnInfo + "</span>";
                                    appenddatagrid.datagrid("reload");//刷新附件清单
                                },
                                error: function (returnInfo) {
                                    //上传失败时显示上传失败信息
                                    document.getElementById('uploadInfo').innerHTML = "<span style='color:Red'>" + returnInfo + "</span>";
                                }
                            });
                        }
                        else {
                            alert("文件类型错误");
                            //将错误信息显示在前端label文本中
                            document.getElementById('fileName').innerHTML = "<span style='color:Red'>错误提示:上传文件应该是.xlsx后缀而不应该是" + file_typename + ",请重新选择文件</span>"
                        }
                    }
                }, {
                    text: '关 闭',
                    handler: function () {
                        $("#ui_pm_upload_dialog").dialog('destroy');

                    }
                }],
                onLoad: function () {

                },
                onClose: function () {
                    $("#ui_pm_upload_dialog").dialog('destroy');  //销毁dialog对象                    
                }
            });
        }
        //根据附件id删除附件，更新表格
        function Delfile(appenddatagrid) {
            var rows = appenddatagrid.datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要删除的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量删除");
                appenddatagrid.datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $.messager.confirm('提示', '确定删除：' + rows[0].AppendName + '？', function (r) {
                if (r) {
                    $.ajax({
                        url: "/Project/DelAppendByID?r=" + Math.random(),
                        data: {
                            ID: rows[0].AppendID,
                            AppendPath: rows[0].AppendPath
                        },
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.success) {
                                $.show_alert("提示", data.msg);
                                $("#ui_pm_dg").datagrid("reload").datagrid('clearSelections').datagrid('clearChecked');
                                appenddatagrid.datagrid("reload");//刷新附件清单
                                ////如果“用户管理”标签页处于打开状态需要刷新，否则被删除的角色还显示，再点编辑用户就出错
                                //if ($('#tabs').tabs('exists', '用户管理')) {
                                //    $('#tabs').tabs('getTab', '用户管理').panel('refresh');
                                //}

                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });
                }
            });
        }
        function downloadfile(appenddatagrid) {
            var rows = appenddatagrid.datagrid("getChecked");
            if (rows.length < 1) {
                $.show_alert("提示", "请先勾选要下载的项目");
                return;
            }
            if (rows.length > 1) {
                $.show_alert("提示", "不支持批量处理");
                appenddatagrid.datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            // var path = "${ctx}/file/download.do?filePath=" + value ;  
            window.open("../uploads/" + rows[0].AppendPath);
        }
        //修改项目节点
        function EditbillPMIndex() {
            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row.length < 1) {
                $.show_alert("提示", "请先勾选要更新的项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量修改项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $("<div/>").dialog({
                id: "ui_pm_edit_dialog",
                href: "/Project/PMEdit",
                title: "更新项目",
                height: $(window).height(),
                width: $(window).width(),
                modal: true,
                toolbar: [{
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        if (lock) { return; } else { lock = true; }
                        $.ajax({     //提交主表数据保存
                            url: "/Project/EditBasicProject?r=" + Math.random(),
                            type: "post",
                            data: {
                                "KeyCode": "EditPMBill",
                                "ProjectID": $("#ProjectID").val(),
                                "ProjectNo": $("#ProjectNo").val(),
                                "ProjectName": $("#ProjectName").val(),
                                "ProjectManager": $("#ProjectManager").val(),
                                "ProjectClerk": $("#ProjectClerk").val(),
                                "Remark": $("#Remark").val(),
                                "Department": $("#comDepartmentList").val(),
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                lock = false;
                                if (data.success) {
                                    $.show_alert("成功", "保存项目主表数据成功！");
                                    //$("#ui_pm_edit_dialog").dialog('destroy');
                                    //$("#ui_pm_dg").datagrid("reload");//.datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        });

                        $.ajax({     //提交节点数据保存
                            url: "/Project/EditPM?r=" + Math.random(),
                            type: "post",
                            data: {
                                "ProjectID": $("#ProjectID").val(),
                                "bsPSTime": $("#bsPSTime").datebox('getValue'),
                                "bsPETime": $("#bsPETime").datebox('getValue'),
                                "bsRSTime": $("#bsRSTime").datebox('getValue'),
                                "bsRETime": $("#bsRETime").datebox('getValue'),
                                "bsRemark": $("#bsRemark").val(),
                                "bsExecutor": $("#bsExecutor").val(),

                                "tyPSTime": $("#tyPSTime").datebox('getValue'),
                                "tyPETime": $("#tyPETime").datebox('getValue'),
                                "tyRSTime": $("#tyRSTime").datebox('getValue'),
                                "tyRETime": $("#tyRETime").datebox('getValue'),
                                "tyRemark": $("#tyRemark").val(),
                                "tyExecutor": $("#tyExecutor").val(),

                                "dnPSTime": $("#dnPSTime").datebox('getValue'),
                                "dnPETime": $("#dnPETime").datebox('getValue'),
                                "dnRSTime": $("#dnRSTime").datebox('getValue'),
                                "dnRETime": $("#dnRETime").datebox('getValue'),
                                "dnRemark": $("#dnRemark").val(),
                                "dnExecutor": $("#dnExecutor").val(),

                                "mePSTime": $("#mePSTime").datebox('getValue'),
                                "mePETime": $("#mePETime").datebox('getValue'),
                                "meRSTime": $("#meRSTime").datebox('getValue'),
                                "meRETime": $("#meRETime").datebox('getValue'),
                                "meRemark": $("#meRemark").val(),
                                "meExecutor": $("#meExecutor").val(),
                                "estworktime": $("#estWorkTime").val(),//预估工时
                                "weight1": $("#weight1").val(),//重量1
                                "weight2": $("#weight2").val(),//重量2
                                "workitem1": $("#workitem1").combogrid("getText"),//工时项目类别1
                                "workitem2": $("#workitem2").combogrid("getText"),// 

                                "cnPSTime": $("#cnPSTime").datebox('getValue'),
                                "cnPETime": $("#cnPETime").datebox('getValue'),
                                "cnRSTime": $("#cnRSTime").datebox('getValue'),
                                "cnRETime": $("#cnRETime").datebox('getValue'),
                                "cnRemark": $("#cnRemark").val(),
                                "cnExecutor": $("#cnExecutor").val()
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                if (data.success) {
                                    $.show_alert("成功", "节点数据保存成功！");
                                    //$("#ui_pm_edit_dialog").dialog('destroy');保存后不自动关闭
                                    // $("#ui_pm_dg").datagrid("reload");//.datagrid('clearSelections').datagrid('clearChecked');
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cross',
                    handler: function () {
                        $("#ui_pm_edit_dialog").dialog('destroy');
                        $("#ui_pm_dg").datagrid("reload");
                    }
                }],
                //修改窗口加载后
                onLoad: function () {
                    bangdingnodedata(row);
                },
                //编辑窗口关闭
                onClose: function () {
                    $("#ui_pm_edit_dialog").dialog('destroy');  //销毁dialog对象 
                    $("#ui_pm_dg").datagrid("reload");//主表更新！
                }
            });

        }
        //查看项目
        function SeebillPMIndex() {
            var row = $("#ui_pm_dg").datagrid("getSelected");
            if (row.length < 1) {
                $.show_alert("提示", "请先勾选要查看的项目");
                return;
            }
            if (row.length > 1) {
                $.show_alert("提示", "不支持批量查看项目");
                $("#ui_pm_dg").datagrid('clearSelections').datagrid('clearChecked');
                return;
            }
            $("<div/>").dialog({
                id: "ui_pm_view_dialog",
                href: "/Project/PMEdit",
                title: "查看项目",
                height: $(window).height(),
                width: $(window).width(),
                modal: true,
                toolbar: [
                {
                    text: '关闭',
                    iconCls: 'icon-cross',
                    handler: function () { $("#ui_pm_view_dialog").dialog('destroy'); }
                }],
                //修改窗口加载后
                onLoad: function () {
                    bangdingnodedata(row);
                },
                onOpen: function () {
                    setTimeout(function () {
                        $(".easyui-textbox").textbox('readonly', true);//设置所有输入项为readonly
                        $(".easyui-datebox").textbox('readonly', true);//设置所有日期输入项为readonly
                        //$("#tt a.l-btn .icon-delete").parent().parent().linkbutton("disable");//禁止附件管理的删除、添加
                        //$("#tt a.l-btn .icon-add").parent().parent().linkbutton("disable");
                        $("#tt a.l-btn .icon-add").parent().parent().hide();
                        $("#tt a.l-btn .icon-delete").parent().parent().hide();
                    }, 2000);

                },
                //编辑窗口关闭
                onClose: function () {
                    $("#ui_pm_view_dialog").dialog('destroy');  //销毁dialog对象                       
                }
            });
        }

        function bangdingnodedata(row) {
            //绑定项目基本信息
            $("#ProjectID").val(row.ProjectID);
            $("#ProjectNo").textbox('setValue', row.ProjectNo);
            $("#ProjectName").textbox('setValue', row.ProjectName);
            $("#ProjectManager").textbox('setValue', row.ProjectManager);
            $("#ProjectClerk").textbox('setValue', row.ProjectClerk);
            $("#CreateBy").textbox('setValue', row.CreateBy);
            $("#CreateTime").textbox('setValue', row.CreateTime);
            $("#UpdateTime").textbox('setValue', row.UpdateTime);
            $("#UpdateBy").textbox('setValue', row.UpdateBy);
            $("#Remark").textbox('setValue', row.Remark);
            $("#comDepartmentList").textbox('setValue', row.Department);
            //$("#com").hide();
            //$("#dep").hide();
            $("#ProjectNo").textbox('enable');
            $("#ProjectName").textbox('enable');
            $("#ProjectManager").textbox('enable');
            $("#ProjectClerk").textbox('enable');
            $("#Remark").textbox('enable');
            //加载当前项目的各节点时间进度信息
            $.ajax({
                url: "/Project/GetPMNodeInfo?r=" + Math.random(),
                type: "post",
                data: { "ProjectID": row.ProjectID, "KeyName": "PMMaintain" },
                dataType: "json",
                timeout: 5000,
                success: function (data) {
                    if (data.success == true) {
                        //单据加载节点信息
                        for (var i = 0; i < data.rows.length; i++) {
                            //项目商务bs
                            if (data.rows[i].NodeID == "2") {
                                $("#bsExecutor").textbox('setValue', data.rows[i].executor);
                                $("#bsPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));//将全局的\号替换为-，使得js能识别为日期格式
                                $("#bsPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#bsRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#bsRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#bsRemark").textbox('setValue', data.rows[i].Remark);
                                //加载附件,data.rows[i].AppendListID
                                var aid = data.rows[i].AppendListID;
                                $('#bsdatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid, $("#bsdatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#bsdatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#bsdatagrid"));
                                        }
                                    }]
                                });
                            }
                                //合同签订ty
                            else if (data.rows[i].NodeID == "3") {

                                $("#tyExecutor").textbox('setValue', data.rows[i].executor);
                                $("#tyPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#tyPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#tyRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#tyRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#tyRemark").textbox('setValue', data.rows[i].Remark);
                                var aid3 = data.rows[i].AppendListID;
                                $('#tydatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid3 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid3, $("#tydatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#tydatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#tydatagrid"));
                                        }
                                    }]
                                });
                            }
                                //设计时间dn
                            else if (data.rows[i].NodeID == "4") {
                                $("#dnExecutor").textbox('setValue', data.rows[i].executor);
                                $("#dnPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#dnPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#dnRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#dnRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#dnRemark").textbox('setValue', data.rows[i].Remark);
                                var aid4 = data.rows[i].AppendListID;
                                $('#dndatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid4 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid4, $("#dndatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#dndatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#dndatagrid"));
                                        }
                                    }]
                                });
                            }
                                //生产制造me,带预估工时
                            else if (data.rows[i].NodeID == "5") {
                                $("#meExecutor").textbox('setValue', data.rows[i].executor);
                                $("#mePSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#mePETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#meRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#meRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#meRemark").textbox('setValue', data.rows[i].Remark);
                                $("#estWorkTime").textbox('setValue', data.rows[i].EstWorkTime);
                                $("#weight1").textbox('setValue', data.rows[i].weight1);
                                $("#weight2").textbox('setValue', data.rows[i].weight2);
                                $("#workitem1").val(data.rows[i].workitem1);//input 赋值
                                $("#workitem2").val(data.rows[i].workitem2);
                                //为工时类绑定下拉选择内容；
                                $("input[id^='workitem']").combogrid({//以workitem开头的id 
                                    delay: 500,
                                    mode: 'remote',
                                    panelWidth: 200,
                                    //value: '请选择类别',
                                    idField: 'itemNo',
                                    textField: 'itemClass',
                                    url: "/Project/GetWorkTimeClass?&r=", //+ Math.random(),//获取工时项目类json数据
                                    columns: [[
                                    //{ field: 'itemNo', title: 'ID', width: 20 },
                                    { field: 'itemClass', title: '类别', width: 150 },
                                    { field: 'Stime', title: '工时', width: 30 }
                                    ]]
                                });
                                //为工时绑定自动计算功能
                                $("#estWorkTime").textbox({
                                    buttonText: "计算工时",
                                    buttonAlign: "right",
                                    onClickButton: function () {
                                        var stime1 = 0, stime2 = 0;
                                        var g1 = $('#workitem1').combogrid('grid');
                                        var g2 = $('#workitem2').combogrid('grid');
                                        if (g1.datagrid('getSelected') == null)//未选择
                                        {
                                            //判断是否符合选项
                                            var text1 = $("#workitem1").combogrid("getText");
                                            var rows = g1.datagrid('getRows');
                                            for (var i = 0; i < rows.length; i++) {
                                                if (text1 == rows[i].itemClass) { stime1 = rows[i].Stime; break; }
                                            }
                                        } else {
                                            stime1 = g1.datagrid('getSelected').Stime;
                                        }
                                        if (g2.datagrid('getSelected') == null)//未选择
                                        {
                                            var text2 = $("#workitem2").combogrid("getText");
                                            var rows = g1.datagrid('getRows');
                                            for (var i = 0; i < rows.length; i++) {
                                                if (text2 == rows[i].itemClass) { stime2 = rows[i].Stime; break; }
                                            }
                                        } else {
                                            stime2 = g2.datagrid('getSelected').Stime;
                                        }
                                        try {
                                            var w1 = $("#weight1").val();
                                            var w2 = $("#weight2").val();
                                            var time = stime1 * w1 + stime2 * w2;
                                            $("#estWorkTime").textbox('setValue', time);
                                        } catch (e) {
                                            $.show_alert("提示", "工时项目类别输入格式有误,请重新输入！");
                                        }

                                    }

                                });


                                var aid5 = data.rows[i].AppendListID;
                                $('#medatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + aid5 + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid5, $("#medatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#medatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#medatagrid"));
                                        }
                                    }]
                                });

                            }
                                //施工管理cn
                            else if (data.rows[i].NodeID == "6") {
                                $("#cnExecutor").textbox('setValue', data.rows[i].executor);
                                $("#cnPSTime").datebox('setValue', data.rows[i].PSTime.replace(/\//g, '-'));
                                $("#cnPETime").datebox('setValue', data.rows[i].PETime.replace(/\//g, '-'));
                                $("#cnRSTime").datebox('setValue', data.rows[i].RSTime.replace(/\//g, '-'));
                                $("#cnRETime").datebox('setValue', data.rows[i].RETime.replace(/\//g, '-'));
                                $("#cnRemark").textbox('setValue', data.rows[i].Remark);
                                var aid6 = data.rows[i].AppendListID;
                                $('#cndatagrid').datagrid({
                                    url: "/Project/GetAppendList?AppendListID=" + data.rows[i].AppendListID + "&r=" + Math.random(),
                                    toolbar: [{
                                        text: '添加',
                                        iconCls: 'icon-add',
                                        handler: function () {
                                            uploadfile(aid6, $("#cndatagrid"));
                                        }
                                    }, {
                                        text: '删除',
                                        iconCls: 'icon-delete',
                                        handler: function () {
                                            Delfile($("#cndatagrid"));
                                        }
                                    }, {
                                        text: '下载附件',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            downloadfile($("#cndatagrid"));
                                        }
                                    }]
                                });
                            }
                        }

                    } else {
                        $.show_alert("错误", data.msg);
                    }
                }
                ,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            });

        }
    </script>
</head>
<body>
    <div id="ui_pm_layout" class="easyui-layout" data-options="fit:true,border:false">
        @*<div data-options="region:'north',split:true,border:true,collapsed:false" title="项目基本信息" style="height:104px;">
            <div id="ui_pm_search">
               
            </div>
        </div>*@
        <div data-options="region:'center',border:false">
            <div class="easyui-panel" title="基本信息" style="width:100%;height:120px;padding:10px;">
                <table class="tableForm" style="width: 99%; height: 99%; background: #F5F5F5;">
                    <tr>
                        <th>
                            项目编码：
                        </th>
                        <td>
                            <input name="txtProjectNo" id="txtProjectNo" class="easyui-validatebox textbox" style="width:150px;height:22px;" data-bind="value:ProjectNo" />
                        </td>

                        <th>
                            项目名称：
                        </th>
                        <td>
                            <input name="txtPMName" id="txtPMName" class="easyui-validatebox textbox" style="width:150px;height:22px;" data-bind="value:ProjectName" />
                        </td>

                        <th>
                            项目状态：
                        </th>
                        <td>
                            <input class="easyui-validatebox textbox" style="width:150px;height:22px;" data-bind="value:FStatus" />

                        </td>

                    <tr>
                        <th>
                            添加时间：
                        </th>
                        <td>
                            <input name="txtAddBeginDate" id="txtAddBeginDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            至：
                        </th>
                        <td>
                            <input name="txtAddEndDate" id="txtAddEndDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>
                        <td colspan="4"></td>
                    </tr>
                </table>   
                 
            </div>
            <div class="easyui-panel" title="项目进度" style="width:100%;height:100px;padding:10px;"> </div>
            <div class="easyui-panel" title="项目管理" style="width:100%;height:100px;padding:10px;"> 
                <a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">项目商务</a>
                <a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">合同签订</a>
                <a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">项目设计</a>
                <a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">生产制造</a>
                <a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">现场施工</a>
            </div>
            
            @*<a href="###" class="easyui-linkbutton" data-options="iconCls:'icon-blank'">icon-blank</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-add">icon-add</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-edit">icon-edit</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-clear">icon-clear</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-remove">icon-remove</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-save">icon-save</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-cut">icon-cut</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-ok">icon-ok</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-no">icon-no</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-cancel">icon-cancel</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-reload">icon-reload</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-search">icon-search</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-print">icon-print</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-help">icon-help</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-undo">icon-undo</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-redo">icon-redo</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-back">icon-back</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-sum">icon-sum</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-tip">icon-tip</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-filter">icon-filter</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-man">icon-man</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-lock">icon-lock</a>
            <a href="###" class="easyui-linkbutton" iconcls="icon-more">icon-more</a>*@
        </div>
    </div>
   

</body>
</html>